home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d11 / zeno2.arc / ZENO.ASM < prev    next >
Encoding:
Assembly Source File  |  1986-10-24  |  12.2 KB  |  347 lines

  1. page 66,132
  2. page
  3. ;  X:0
  4. ;
  5. ; ZENO:  June 11, 1986
  6. ;
  7. ;   Modified Sept 4, 1986 by R Tansky to fix 40-character mode
  8. ;
  9. cseg    segment para public 'code'
  10. zeno            proc  far
  11.         assume  cs:cseg, ds:cseg, es:cseg, ss:cseg
  12.         org     100h            ; for .COM file
  13. ;
  14. environment     equ   2Ch
  15. command         equ   80h
  16. slashk          equ   'K/'
  17. slashk2         equ   'k/'
  18. ;
  19. ;-------------------------------
  20. ; enter here on initial load
  21. ;-------------------------------
  22. ;
  23. start:
  24. ;
  25.         jmp     near ptr load_pgm
  26. ;
  27. video_vector    dd   0
  28. core_seg        dw   0
  29. ;
  30. bios_cursor_posn  label  dword
  31. bios_ofst       dw   00h        ; offset for active page
  32.                 dw   40h        ; segment for bios data
  33.  
  34. ;
  35. crt_mode        db   2          ; passes if 4, 5, or 6
  36. active_page     db   0
  37. cursor_type     dw   0B0Ch      ; DOS cursor
  38. ;
  39. video_posn      label  dword
  40. video_ofst      dw     0        ; offset against video_seg
  41. video_seg       dw     0
  42. ;
  43. video_addr      dw     0
  44. ;
  45. onesixty        db   160
  46. ;
  47. ;-------------------------------
  48. ; enter here from int 10h
  49. ;-------------------------------
  50. ;
  51. video_int:
  52.         sti                     ; interrupts on
  53.         pushf                   ; save flags
  54.         cmp     cs:crt_mode,7   ; check for b/w
  55.         je      video_keep      ; go if b/w
  56.         cmp     cs:crt_mode,4   ; check for graphics
  57.         jnc     video_exit      ; go if graphics
  58.         cmp     cs:crt_mode,1   ; check for 40-cols
  59.         jng     video_exit      ; go if 40-col
  60. video_keep:
  61.         cmp     ah,2            ; to set cursor
  62.         je      set_cursor
  63.         cmp     ah,10           ; to write char only
  64.         je      write_char
  65.         cmp     ah,9            ; to write char/attr
  66.         je      route_write_both
  67.         cmp     ah,3            ; to read cursor
  68.         je      route_read_cursor
  69.         cmp     ah,1            ; to set type
  70.         je      route_set_type
  71.         cmp     ah,0            ; to set mode
  72.         je      route_set_mode
  73.         cmp     ah,5            ; to set page
  74.         je      route_set_page
  75.         cmp     ax,0FF00h       ; kill code
  76.         je      route_do_kill   ; go if found
  77. video_exit:
  78.         popf                    ; restore flags
  79.         jmp     cs:dword ptr video_vector ; hand off interrupt
  80. ;
  81. route_write_both:
  82.         jmp     write_both
  83. ;
  84. route_read_cursor:
  85.         jmp     read_cursor
  86. ;
  87. route_set_page:
  88.         jmp     set_page
  89. ;
  90. route_set_type:
  91.         jmp     set_type
  92. ;
  93. route_set_mode:
  94.         jmp     set_mode
  95. ;
  96. route_do_kill:
  97.         jmp     do_kill
  98. ;
  99. write_char:
  100.         cmp     bh,cs:active_page ; check page
  101.         jne     video_exit      ; pass to bios
  102.         cmp     cx,1            ; for multiple write
  103.         jne     video_exit      ; pass to bios
  104.         push    di              ; save
  105.         push    es              ; save
  106.         les     di,cs:video_posn ; get screen position
  107.         cld                     ; frontwards
  108.         stosb                   ; dump to screen
  109.         pop     es              ; restore
  110.         pop     di              ; restore
  111.         popf                    ; restore flags
  112.         iret                    ; done
  113. ;
  114. set_cursor:
  115.         cmp     bh,cs:active_page ; check page
  116.         jne     video_exit      ; pass to bios
  117.         push    ax              ; save
  118.         push    cx              ; save
  119.         push    dx              ; save
  120.         push    di              ; save
  121.         push    es              ; save
  122.         add     cs:video_ofst,2 ; for next char
  123.         les     di,cs:bios_cursor_posn ; get bios
  124.         inc     byte ptr es:[di] ; assume next
  125.         cmp     es:[di],dx      ; check if next
  126.         je      offset_ready    ; go if next
  127.         mov     ax,dx           ; get req posn
  128.         mov     es:[di],ax      ; save req posn
  129.         mov     cx,ax           ; copy posn
  130.         mov     al,ah           ; rows in al
  131.         mul     cs:onesixty     ; for bytes
  132.         xor     ch,ch           ; cols in cx
  133.         shl     cx,1            ; for video
  134.         add     ax,cx           ; offset in ax
  135.         mov     cs:video_ofst,ax ; store offset
  136. offset_ready:
  137.         mov     cx,cs:video_ofst ; offset in cx
  138.         shr     cx,1            ; for byte count
  139.         mov     ah,14           ; cursor MSB register
  140.         mov     dx,cs:video_addr ; 6845 index addr
  141.         mov     al,ah           ; get register
  142.         out     dx,al           ; send register
  143.         inc     dx              ; 6845 data addr
  144.         mov     al,ch           ; get cursor MSB
  145.         out     dx,al           ; send cursor MSB
  146.         dec     dx              ; 6845 index addr
  147.         mov     al,ah           ; cursor MSB register
  148.         inc     al              ; cursor LSB register
  149.         out     dx,al           ; send register
  150.         inc     dx              ; 6845 data addr
  151.         mov     al,cl           ; get cursor LSB
  152.         out     dx,al           ; send cursor LSB
  153.         pop     es              ; restore
  154.         pop     di              ; restore
  155.         pop     dx              ; restore
  156.         pop     cx              ; restore
  157.         pop     ax              ; restore
  158.         popf                    ; restore flags
  159.         iret                    ; done
  160. ;
  161. route_video_exit:
  162.         jmp     video_exit
  163. ;
  164. write_both:
  165.         cmp     bh,cs:active_page ; check page
  166.         jne     route_video_exit ; pass to bios
  167.         cmp     cx,1            ; check multiple write
  168.         jne     route_video_exit ; pass to bios
  169.         push    ax              ; save
  170.         push    di              ; save
  171.         push    es              ; save
  172.         mov     ah,bl           ; get attribute
  173.         les     di,cs:video_posn ; get screen position
  174.         cld                     ; frontwards
  175.         stosw                   ; dump to screen
  176.         pop     es              ; restore
  177.         pop     di              ; restore
  178.         pop     ax              ; restore
  179.         popf                    ; restore flags
  180.         iret                    ; done
  181. ;
  182. read_cursor:
  183.         cmp     bh,cs:active_page ; check page
  184.         jne     route_video_exit ; pass to bios
  185.         push    di              ; save
  186.         push    es              ; save
  187.         les     di,cs:bios_cursor_posn ; get bios
  188.         mov     dx,es:[di]      ; get bios posn
  189.         mov     cx,cs:cursor_type ; get type
  190.         pop     es              ; restore
  191.         pop     di              ; restore
  192.         popf                    ; restore flags
  193.         iret                    ; done
  194. ;
  195. set_page:
  196.         push    ax              ; save
  197.         mov     cs:active_page,al ; save page
  198.         xor     ah,ah           ; page in ax
  199.         shl     ax,1            ; for word count
  200.         add     ax,50h          ; offset for page zero
  201.         mov     cs:bios_ofst,ax ; save offset
  202.         pop     ax              ; restore
  203.         jmp     video_exit      ; pass to bios
  204. ;
  205. set_type:
  206.         mov     cs:cursor_type,cx ; save type
  207.         jmp     video_exit      ; pass to bios
  208. ;
  209. set_mode:
  210.         mov     cs:crt_mode,al  ; save mode
  211.         mov     cs:video_ofst,0 ; top left
  212.         jmp     video_exit      ; done
  213. ;
  214. ; remove routine from memory
  215. ;
  216. do_kill:
  217.         mov     ax,cs           ; get code segment
  218.         mov     ds,ax           ; set data segment
  219.         mov     es,ax           ; set extra segment
  220.         push    ds              ; save
  221.         mov     ax,2510h        ; to set video vector
  222.         lds     dx,video_vector ; get original
  223.         int     21h             ; set vector
  224.         pop     ds              ; restore
  225.         mov     ah,49h          ; for free memory fn
  226.         int     21h             ; do free memory
  227.         push    es              ; save
  228.         mov     bx,environment  ; get env. segment
  229.         mov     es,cs:[bx]
  230.         mov     ah,49h          ; for free memory fn
  231.         int     21h             ; do free memory
  232.         pop     es              ; restore
  233.         lea     dx,kill_msg     ; get message
  234.         mov     ah,9            ; for screen write
  235.         int     21h             ; do write
  236.         popf                    ; restore flags
  237.         iret                    ; return to ZENO/K
  238. ;
  239. kill_msg        db   13,10,'ZENO Removed',13,10,'$'
  240. ;
  241. end_core:
  242. ;
  243. ;-------------------------------
  244. ; enter here to load program
  245. ;-------------------------------
  246. ;
  247. load_pgm:
  248. ;
  249. ; check for color screen; set video segment
  250. ;
  251.         mov     video_seg,0B000h ; assume mono
  252.         mov     video_addr,03B4h ; assume mono
  253.         int     11h             ; for equip check
  254.         and     ax,30h          ; isolate adapter
  255.         cmp     ax,30h          ; check for mono
  256.         je      mono_screen     ; go if found
  257.         mov     video_seg,0B800h ; reset for color
  258.         mov     video_addr,03D4h ; reset for color
  259. mono_screen:
  260. ;
  261. ; check command line
  262. ;
  263.         mov     si,command      ; get command line
  264.         mov     al,cs:[si]      ; length of argument
  265.         or      al,al           ; check for zero
  266.         je      command_clear   ; go if zero
  267.         cmp     al,2            ; for kill request
  268.         jne     retry           ; go if not
  269.         cmp     word ptr cs:[si+1],slashk2 ; check for '/k'
  270.         je      killme          ; go if not
  271.         cmp     word ptr cs:[si+1],slashk ; check for '/K'
  272.         jne     retry           ; go if not
  273. killme: mov     ax,0FF00h       ; set for kill
  274.         int     10h             ; order kill
  275.         int     20h             ; exit to DOS
  276. retry:
  277.         lea     dx,retry_msg    ; get message
  278.         mov     ah,9            ; for print fn
  279.         int     21h             ; print message
  280.         int     20h             ; exit to DOS
  281. command_clear:
  282. ;
  283. ; find and set current variables
  284. ;
  285.         les     di,bios_cursor_posn ; set to 0040:0000
  286.         mov     al,es:[di+49h]  ; get current mode
  287.         mov     crt_mode,al     ; save mode
  288.         mov     ax,es:[di+60h]  ; get cursor type
  289.         mov     cursor_type,ax  ; save type
  290.         mov     al,es:[di+62h]  ; get active page
  291.         mov     active_page,al  ; save active page
  292.         xor     ah,ah           ; page in ax
  293.         shl     ax,1            ; for word count
  294.         add     ax,50h          ; offset for page zero
  295.         mov     bios_ofst,ax    ; save offset
  296. ;
  297. ; set video interrupt
  298. ;
  299.         mov     core_seg,cs     ; set core segment
  300.         push    es              ; save
  301.         mov     ax,3510h        ; to get vector
  302.         int     21h             ; get vector
  303.         mov     word ptr video_vector,bx ; store offset
  304.         mov     word ptr video_vector+2,es ; store segment
  305.         pop     es              ; restore
  306.         mov     ax,2510h        ; to set video vector
  307.         lea     dx,video_int    ; get offset; ds OK
  308.         int     21h             ; set vector
  309. ;
  310. ; print messages; terminate and stay resident
  311. ;
  312.         lea     dx,install_msg  ; get message
  313.         mov     ah,9h           ; for print fn
  314.         int     21h             ; print message
  315.         cmp     video_seg,0B000h ; check for mono
  316.         je      skip_message    ; go if mono
  317.         lea     dx,color_msg    ; get message
  318.         mov     ah,9h           ; for print fn
  319.         int     21h             ; print message
  320. skip_message:
  321.         lea     dx,finish_msg   ; get termination
  322.         mov     ah,9h           ; for print fn
  323.         int     21h             ; print ternination
  324.         lea     ax,end_core     ; last address in core
  325.         add     ax,2Fh          ; make bumper
  326.         mov     cl,4            ; for shift
  327.         shr     ax,cl           ; convert to paras
  328.         mov     bx,ax           ; no. paras to keep
  329.         mov     dx,ax           ; same
  330.         mov     ah,4Ah          ; for setblock
  331.         int     21h             ; do setblock
  332.         mov     ax,3100h        ; for keep; no exit code
  333.         int     21h             ; exit and stay resident
  334. ;
  335. install_msg     db   13,10,'ZENO Successfully Installed$'
  336. ;
  337. color_msg       db   ';',13,10,'May cause some snow.$'
  338. ;
  339. finish_msg      db   13,10,'$'
  340. ;
  341. retry_msg       db   13,10,'No Action:  Invalid Command Line',13,10,7,'$'
  342. ;
  343. zeno            endp
  344. cseg            ends
  345.         end     start
  346.  
  347.